package home

import "fmt"

func sc(p int8, n int8) int8 {
	var r int8 = 0
	switch p {
	case 0, 1, 2:
		switch n {
		case 0, 3:
			r = 0
		case 2, 5:
			r = 1
		case 1, 4:
			r = 3
		case 6:
			r = 6
		}
	case 3, 4, 5:
		switch n {
		case 0, 3:
			r = 4
		case 2, 5:
			r = 5
		case 1, 4, 6:
			r = 2
		}
	case 6:
		r = n
	}

	return r
}

func next(num []int8) []int8 {
	num = append([]int8{0}, append(num, 6)...)
	var num2 []int8
	for i := 0; i < len(num)-1; i++ {
		num2 = append(num2, sc(num[i], num[i+1]))
	}

	if num2[0] == 0 {
		num2 = num2[1:]
	}

	e := len(num2) - 1
	if num2[e] == 6 {
		num2 = num2[:e]
	}

	return num2
}

func path(num []int8) {
	for true {
		if len(num) <= 1 {
			break
		}
		fmt.Println(num)
		num = next(num)
	}
}
